package com.abc.robot01.vivemodel

import android.util.Log
import androidx.compose.runtime.mutableStateListOf
import androidx.lifecycle.ViewModel
import com.abc.robot01.fragment.QAFragment.DataA
import com.abc.robot01.room.DatabaseContext

class QAFragmentViewModel : ViewModel() {

    val TAG="QAFragmentViewmodel"

    val  questionList = mutableStateListOf(DataA(question = ""))

    fun getData() {
        questionList.clear()
        DatabaseContext.getCmdDao().queryAll().forEach {
            val questions = DatabaseContext.getChatQuestionDao().queryCustomQuestionByCmdId(it.id.toString())
            questionList.add(DataA(cmdId=it.id, question = questions[0].question, date = questions[0].date ))
            Log.e("QAFragment",""+questions[0]);
        }
    }

    fun searcByQuestion(value: String) {
        questionList.clear()
        DatabaseContext.getChatQuestionDao().queryByQuestion(value).forEach {
            val questions = DatabaseContext.getChatQuestionDao().queryCustomQuestionByCmdId(it.cmd_id)






        }
    }

    init {
        getData()
    }
}

